package com.LA_houseLease.common.exception;


import com.LA_houseLease.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handler(Exception e){
        log.warn("全局异常控制器...........异常信息:{}",e.getMessage());
        e.printStackTrace();
        return Result.fail();
    }


    @ExceptionHandler(houseLeaseException.class)
    public Result handler(houseLeaseException e){
        log.warn("houseLeaseException异常控制器...........状态码:{},异常信息:{}",e.getCode(),e.getMessage());
        e.printStackTrace();
        return Result.fail(e.getCode(),e.getMessage());
    }

}
